<?php

function apache_extras_definetypes() {
	$r[] = 'ae_etags';
	$r[] = 'ae_expires';
	$r[] = 'ae_deflate';
	$r[] = 'ae_speling';
	$r[] = 'ae_autoindex';
	return $r;
}

function apache_extras_add_lang(&$data) {
	global $T;
	switch($data['lang']) {
		default:
			$T['ss']['ae_etags'] = 'Disable ETags (for clusters)';
			$T['ss']['ae_expires'] = 'Expiration Headers';
			$T['ss']['ae_deflate'] = 'Deflate Content';
			$T['ss']['ae_speling'] = 'Check URL Spelling';
			$T['ss']['ae_autoindex'] = 'Enable Autoindex';
			$T['Apache Extras'] = 'Apache Extra Configs';
			
			break;
	}
}

function apache_extras_add_cfg(&$cfg) {
	global $cfg;
	
	$types = apache_extras_definetypes();
	
	foreach($types as $type) {
		if (!stristr($cfg['sslang'], ",$type")) {
			$cfg['sslang'].= ",$type";
			
			// Open the template file
			$tpl_file = $cfg['basedir'].'/httpd/templates/'.$type.'.httpd.tpl';
	
			if(!is_readable($tpl_file)) {
				echo $T['err']['template']['file'];
				return false;
			} else {
				$tpl = file_get_contents($tpl_file);
			}
			
			$cfg['ss'][$type] = $tpl;
		}
	}
}

function  apache_extras_template(&$ret) {
	global $cfg;

	$template['title'] = 'Apache Extras';
	$template['servicename'] = 'httpd';
	$template['active'] = true;
	
	$types = apache_extras_definetypes();
	
	foreach($types as $type) {
		$template['file'][] = array('filename' => $type);
	}

	$ret[] = $template;
}

?>
